import React, { Component } from 'react'
import './App.css'
import { CSSTransition } from 'react-transition-group'

class Boss extends Component {
  constructor(props) {
    super(props)
  
    this.state = {
       isShow: false
    }
    this.toToggle = this.toToggle.bind(this);
  }
  
  render() {
    return (
      <div>
        <CSSTransition
          in={this.state.isShow}   //用于判断是否出现的状态
          timeout={2000}           //动画持续时间
          classNames="boss-text"   //className值，防止重复
          unmountOnExit   // 在元素退场时，自动把DOM也删除
        >
          <div>Boss级人物--老朱</div>
        </CSSTransition>
        <div><button onClick={this.toToggle}>召唤Boss</button></div>
      </div>
    );
  }

  toToggle() {
    this.setState({
      isShow: !this.state.isShow
    })
  }
}
export default Boss;